//
// Created by ASUS on 2024/5/14/星期二.
//
#include <bits/stdc++.h>
using namespace std;

template<typename T>
class BIT{
private:
	vector<T> tree,b;
public:
	BIT(vector<int>&a){
		b=a;
		sort(b.begin(), b.end());
		b.erase(unique(b.begin(), b.end()),b.end());//排序去重
		tree.resize(b.size()+1);
	}

	void clear(){
		fill(tree.begin(), tree.end(),0);
	}

	inline int lowbit(int i){
		return i&-i;
	}

	void add(int i){
		i=lower_bound(b.begin(), b.end(), i) - b.begin()+1;
		while(i<tree.size()){
			tree[i]++;
			i+= lowbit(i);
		}
	}

	T query(int i){
		T res=0;
		while(i>0){
			res+=tree[i];
			i-= lowbit(i);
		}
		return res;
	}

	T query(int l,int r){
		return query(upper_bound(b.begin(), b.end(),r) - b.begin())- query(lower_bound(b.begin(), b.end(),l) - b.begin());
	}

	int operator<(T x){
		return query(lower_bound(b.begin(), b.end(),x) - b.begin());
	}
	int operator<=(T x){
		return query(upper_bound(b.begin(), b.end(),x) - b.begin());
	}
	int operator>(T x){
		return query(upper_bound(b.begin(), b.end(),x) - b.begin()+1,b.size());
	}
	int operator>=(T x){
		return query(lower_bound(b.begin(), b.end(),x) - b.begin()+1,b.size());
	}
	void operator+(T x){
		add(x);
	}
};


int main(){

	vector<int> a;//原始数组
	int diff=1;

	long ans=0L;
	BIT<int> t(a);//下标从1开始
	for (int x : a) {
		ans += t<=x + diff;//+的优先级比<=的优先高
		t+x;
	}
	return ans;
}
/* 查询<x的元素个数 t.query(lower_bound(b.begin(), b.end(),x) - b.begin());
 * 查询<=x的元素个数 t.query(upper_bound(b.begin(), b.end(),x) - b.begin());
 * 查询>x的元素个数 t.query(upper_bound(b.begin(), b.end(),x) - b.begin()+1,b.size());
 * 查询>=x的元素个数 t.query(lower_bound(b.begin(), b.end(),x) - b.begin()+1,b.size());
 * */